<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>IMS&PCF操作维护系统</title>
    <!--   meta  begin  -->
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="Pragma" content="no-cache"/>
    <meta http-equiv="Cache-Control" content="no-cache"/>
    <!--<meta http-equiv="X-Frame-Options" content="SAMEORIGIN">-->
    <!--   meta  end  -->
    <!--   link style begin  -->
    <link rel="stylesheet" type="text/css" href="/static/css/style.css?v=20191006"/>
    <link rel="stylesheet" type="text/css" href="/static/css/homeStyle.css?v=20191006"/>
    <script type="text/javascript" src="/static/public/translate.js?v=20191006"></script>
    <script type="text/javascript" src="/static/public/jquery-1.6.3.min.js"></script>

    <script type="text/javascript" src="/static/css/difference.js?v=20191006"></script>
    <script defer="defer" type="text/javascript">
        //home.asp嵌套Iframe里面
        if (window.top.location.href != location.href) {
            window.top.location.href = location.href;
        }
        var T = null;

        function translate() {
            $("#ok_2").text(T.BTN.Confirm);
            $("#login_logo").removeClass().addClass(T.Home.LogoClass);
            $("#loginComba").removeClass().addClass(T.Home.CombaLoginBtnClass);
            $("#loginJeson").removeClass().addClass(T.Home.JesonLoginBtnClass);
            $("#user").text(T.Home.User);
            $("#pwd").html(T.Home.Pwd);
            $("#password").focus();
            $("#userRole").text(top.T.Home.UserType);
        }


        $(document).ready(function () {
            //home.asp嵌套Iframe里面
            if (window.top.location.href != location.href) {
                window.top.location.href = location.href;
            }
            initValue("ZH");

            var str = location.href;
            var num = str.indexOf("?");
            str = str.substr(num + 1);
            num = str.indexOf("=");
            str = str.substr(num + 1);
            if (str == "true") {
                var username = "user";
                var pwd = "123456";
                var role = "familyUser";

                pwd = md5(pwd);
                login(username, pwd, role);
            }
        });

        function initValue(language) {
            if (language == "EN") {
                T = T_EN;
            } else {
                T = T_ZH;
            }
            translate();

            /* 给密码输入框绑定keypress事件 */
            $("#password").attr("maxLength", 20).keypress(function (event) {
                var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;


                if (keyCode == 13) {/* keyCode=13: enter 事件触发登陆动作 */
                    checkLogin();
                }
            }).val("");

            $("#userName").val(GetCookie("username"));

            /* 如果用cookies中用户名不为空,焦点置于密码框 */
            var username = $("#userName").val();
            if (username == "") {
                $("#userName").focus();
            } else {
                $("#password").focus();
            }

            $(window).resize();
        }

        function checkLogin() {
            var username = $("#userName").val();
            var pwd = $("#password").val();
            var role = 'root';
            login(username, pwd, role);
        }

        function login(account, passcode, role) {
            /* login 函数应避免使用Modal，home.asp不再加载Modal */
            var error = function (data) {
                setErrMSG("用户名或密码错误");
            };
            var url = "/login.asp";
            var tmpValue = new Date();
            $.post(
                url,
                {
                    username: account,
                    password: passcode
                },
                function (data) {
                    if (data.status==200) {
                        sessionStorage.setItem("token",data.access_token);
                        sessionStorage.setItem("refresh_token",data.refresh_token);
                        document.forms[0].action = "main.asp";
                        document.forms[0].target = "_top";
                        document.forms[0].submit();
                    } else {
                        error(data.msg);
                    }
                }
            );
        }


        $(window).resize(function () {
            action_resize();
        });

        function action_resize() {
            var $window = $(window);
            var height = $window.height();
            var width = $window.width();
            $("#coverPage").css({height: height, width: width});
        }

        function loginBtnMouseover() {
            $("#loginComba").removeClass().addClass(T.Home.CombaLoginHoverBtnClass);
        }

        function loginBtnMouseout() {
            $("#loginComba").removeClass().addClass(T.Home.CombaLoginBtnClass);
        }


        function setErrMSG(msg) {
            $("#errorTips").text(msg);
        }
    </script>
</head>
<body style="overflow:hidden;width: 100%;height: 100%;">
<table id="loginWindow" border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td id="loginWindowFstTd" height="25%">&nbsp;</td>
    </tr>
    <tr>
        <td valign="top" class="centerBg">
            <table border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td colspan="3" id="login_logo" align="center" style="font-size: 20px;padding-top: 10px">IMS&PCF操作维护系统</td>
                </tr>
                <tr>
                    <td height="156" colspan="3" valign="middle" class="loginForm">

                        <table width="80%" border="0" align="right" cellpadding="0" cellspacing="0" class="formTable">

                            <!--
                              <tr>
                                <td nowrap="nowrap" align="right">
                                  用户类型：
                                </td>
                                <td>
                                  <select id="role" style="width: 170px;">
                                    <option value="familyUser">普通用户</option>
                                    <option value="root">管理员</option>
                                  </select>
                                </td>
                              </tr>
                          -->

                            <tr id="roleSelect" style="display: none;">
                                <td id="userRole" align="right"></td>
                                <td><select id="role" style="width: 170px;"></select></td>
                            </tr>
                            <tr>
                                <td id="user" width="13%" height="35" align="right"></td>
                                <td width="87%">
                                    <input id="userName" name="userName" type="text" class="userInput" value=""
                                           size="25"/>
                                </td>
                            </tr>
                            <tr>
                                <td id="pwd" height="35" align="right"></td>
                                <td>
                                    <input id="password" name="password" type="password" class="passwordInput" value=""
                                           size="25"
                                           autocomplete="off"/>
                                    <input type="hidden" id="md5UserName" name="md5UserName" value="">
                                    <input type="hidden" id="md5Password" name="md5Password" value="">
                                </td>
                            </tr>
                            <tr>
                                <td>&nbsp;</td>
                                <td colspan="1" width="400px"><label id="errorTips"
                                                                     style="color: rgb(144,0,0);">&nbsp;</label></td>
                            </tr>
                            <tr id="JesonLoginTR">
                                <td height="35" align="right">&nbsp;</td>
                                <td>
                                    <input type="button" name="loginBtn" class="login_btn" value=""
                                           onclick="checkLogin();"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr id="CombaLoginTR">
                    <td id="login_formLeft">&nbsp;</td>
                    <td id="loginComba" onclick="checkLogin();" onmouseover="loginBtnMouseover();"
                        onMouseOut="loginBtnMouseout();">&nbsp;
                    </td>
                    <td id="login_formRight">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="3" class="loginCopyright">
                        <table width="540" border="0" align="left" cellpadding="0" cellspacing="0">
                            <tr>
                                <td align="center"><span id="copyright"></span></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <form method="post">
        <input id="X-CSRFToken" name="X-CSRFToken" type="hidden" value=""/>
    </form>
</table>
</body>
<!--   link script begin -->
<script type="text/javascript" src="/static/public/Utilities.js?v=20191006"></script>
<script type="text/javascript" src="/static/public/md5.js"></script>
<!--   link script end -->
</html>
